#include <iostream>
#include <pthread.h>
#include <unistd.h>

void *thfunc(void *arg)
{
    std::cout << "sub thread is running" << std::endl;
    return NULL;
}

int main()
{
    pthread_t tid;
    pthread_attr_t thread_attr;
    struct sched_param thread_param;
    size_t stack_size;
    int res;

    res = pthread_attr_init(&thread_attr);

    res = pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);

    res = pthread_create(&tid, &thread_attr, thfunc, NULL);

    std::cout << "main thread will exit" << std::endl;
    sleep(1);
    return 0;
}